package org.jeecg.modules.yw.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

import javax.annotation.Resource;

import org.jeecg.modules.yw.entity.WorkerCompanyRelation;
import org.jeecg.modules.yw.mapper.WorkerCompanyRelationMapper;
import org.jeecg.modules.yw.service.IWorkerCompanyRelationService;
import org.jeecg.modules.yw.vo.NqVo;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 内勤工人表
 * @Author: jeecg-boot
 * @Date:   2025-04-22
 * @Version: V1.0
 */
@Service
public class WorkerCompanyRelationServiceImpl extends ServiceImpl<WorkerCompanyRelationMapper, WorkerCompanyRelation> implements IWorkerCompanyRelationService {

    @Override
    public IPage<WorkerCompanyRelation> pageInfo(Page<WorkerCompanyRelation> page, String name) {
        return baseMapper.pageInfo(page,name);
    }
	/**
	 * 根据门窗企业id得到中控人员id
	 */
	@Resource
	private WorkerCompanyRelationMapper workCompanyRelationMapper;
	public String getWorkersByCompanyId(String companyId) {
        QueryWrapper<WorkerCompanyRelation> qw = new QueryWrapper<>();
        qw.eq("company_id", companyId);
        List<WorkerCompanyRelation> list = workCompanyRelationMapper.selectList(qw);
        String ids = "";
        for (WorkerCompanyRelation obj:list) {
        	ids += obj.getWorkerId()+",";
        }
        if (ids.endsWith(",")) {
        	ids = ids.substring(0, ids.length() - 1);
        }
        return ids;
	}

    @Override
    public List<NqVo> nqlist(List<String> roleidstr) {
        return workCompanyRelationMapper.nqlist(roleidstr);
    }
}
